package com.itheimamobileguard.activitys;

import com.example.mobile.R;
import com.itheimamobileguard.ui.SettingView;

import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class SettingCenterActivity extends Activity {
	private SettingView sv_autoUpdate;
	private SettingView sv_blacknumber;
	private SharedPreferences sp;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting);
		sp = getSharedPreferences("config", MODE_PRIVATE);
		
		sv_autoUpdate = (SettingView) findViewById(R.id.sv_autoUpdate);
		sv_autoUpdate.setChecked(sp.getBoolean("autoUpdate", false));
		/*sv_autoUpdate.setTitle("自动更新设置");
		sv_autoUpdate.setDesc(new String[]{"自动更新已经开启","自动更新没有开启"}, sp.getBoolean("autoUpdate", false));*/
		sv_autoUpdate.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Editor editor = sp.edit();
				//判断勾选的状态
				if(sv_autoUpdate.isChecked()){
					editor.putBoolean("autoUpdate", false);
					editor.commit();
					sv_autoUpdate.setChecked(false);
				}else{
					editor.putBoolean("autoUpdate", true);
					sv_autoUpdate.setChecked(true);
					editor.commit();
				}
			}
		});
		
		sv_blacknumber = (SettingView) findViewById(R.id.sv_blacknumber);
	}
}
